<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta name="renderer" content="webkit">
    <title>注册账号</title>
    <link rel="stylesheet" th:href="@{/theme/css/base.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/theme/css/login.css}">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <script th:src="@{/theme/js/jquery-3.1.1.min.js}"></script>
    <script th:src="@{/theme/js/checkcode.js}"></script>
    <script th:src="@{/layui/layui.all.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/searchToPage.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/encrypt/aes.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/encrypt/jsencrypt.min.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/encrypt/pad-zeropadding.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/encrypt/security.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/encrypt/random.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/encrypt/sendEncrypt.js}"></script>

    <script>

        function email_res() {
            var password=$("#email_password").val();
            var password1=$("#email_confirm_password").val();
            var account=$("#email").val();
            var auth_code=$("#email_auth_code").val();
            var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); //正则表达式
            if(account == ""||password == ""){ //输入不能为空
                layer.msg('输入不能为空!',{time:800},function(){

                });
            }else if(!reg.test(account)){ //正则验证不通过，格式不对
                layer.msg('请输入正确的邮箱格式!',{time:800},function(){
                });
            }else if(password!=password1)
            {
                layer.msg('密码不一致',{time:800},function(){
                });
            } else {
            $.ajax({
                url : "/user/register",
                dataType : "json",
                data : sendEncrypt(JSON.stringify(
                    {"password" : password , "account" : account , "auth_code" :auth_code}
                )),
                contentType: "application/json",
                success: function (data) {
                    data=JSON.parse(receiveEncrypt(data));
                    if(data["result"]=="ok"){
                        layer.msg('注册成功',{time:800},function(){
                            window.location="login"
                        });
                    }else if(data["result"]=="fail"){
                        layer.msg('注册失败',{time:800},function(){

                        });
                    }else if(data["result"]=="noCode"){
                        layer.msg('验证码错误',{time:800},function(){

                        });
                    }else if(data["result"]=="noSession"){
                        layer.msg('验证码失效，请重新发送验证码',{time:800},function(){

                        });
                    }else{
                        layer.msg('系统错误',{time:800},function(){

                        });
                    }
                },
                type : "post"
            });
            }
        };
        function phone_res() {
            var password=$("#phone_password").val();
            var password1=$("#phone_confirm_password").val();
            var account=$("#phone").val();
            var length=$("#phone").length;
            var auth_code=$("#phone_auth_code").val();
            var reg = /^1(3|4|5|6|7|8)[0-9]{9}$/;
            if(account =="") {
                layer.msg('手机号码不能为空！', {time: 1000}, function () {
                });
            } else if(length!=11&&(!reg.test(account))) {
                layer.msg('请输入有效的手机号码，必须为11位！', {time: 1000}, function () {
                });
            } else if(password ==""&&password1=="") {
                layer.msg('密码不能为空！', {time: 1000}, function () {
                });
            }else if(password!=password1) {
                layer.msg('密码不一致',{time:800},function(){
                });
            }else{
                $.ajax({
                    url: "/user/register",
                    dataType: "json",
                    data: sendEncrypt(JSON.stringify(
                        {"password": password, "account": account, "auth_code": auth_code}
                    )),
                    async: false,
                    contentType: "application/json",
                    success: function (data) {
                        data=JSON.parse(receiveEncrypt(data));
                        if (data["result"] == "ok") {
                            layer.msg('注册成功', {time: 1000}, function () {
                                window.location="login"
                            });
                        } else if (data["result"] == "fail") {
                            layer.msg('注册失败', {time: 1000}, function () {

                            });
                        } else if (data["result"] == "noCode") {
                            layer.msg('验证码错误', {time: 1000}, function () {

                            });
                        } else if (data["result"] == "noSession") {
                            layer.msg('验证码失效，请重新发送验证码', {time: 1000}, function () {

                            });
                        } else {
                            layer.msg('系统错误', {time: 1000}, function () {

                            });
                        }
                    },
                    type: "post"
                });
            }
        };
        function email_get_auth_code() {
            var email=$("#email").val();
            var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); //正则表达式
            if(!reg.test(email)){ //正则验证不通过，格式不对
                layer.msg('请输入正确的邮箱格式!',{time:800},function(){
                });
            }else{
                $.ajax({
                    url: "/user/registerEmailAuthCode",
                    data:  sendEncrypt(JSON.stringify(
                        {"email": email}
                    )),
                    dataType: "json",
                    async: false,
                    contentType: "application/json",
                    success: function (data) {
                        data=JSON.parse(receiveEncrypt(data));
                        if (data["result"] == "ok") {
                            layer.msg('发送成功', {time: 1000}, function () {

                            });
                        } else if (data["result"] == "fail") {
                            layer.msg('发送失败', {time: 1000}, function () {

                            });
                        } else if (data["result"] == "exit") {
                            layer.msg('该邮箱已经被注册！', {time: 1000}, function () {
                            });
                        } else {
                            layer.msg('系统错误', {time: 1000}, function () {
                            });
                        }

                    },
                    type: "post"
                });
            }
        }
        function phone_get_auth_code() {
            var account=$("#phone").val();
            var length=$("#phone").length;
            var reg = /^1(3|4|5|6|7|8)[0-9]{9}$/;
            var phone=$("#phone").val();
            if(account =="") {
                layer.msg('手机号码不能为空！', {time: 1000}, function () {
                });
            } else if(length!=11&&(!reg.test(account))) {
                layer.msg('请输入有效的手机号码，必须为11位！', {time: 1000}, function () {
                });
            }else {
                $.ajax({
                    url: "/user/registerPhoneAuthCode",
                    data:  sendEncrypt(JSON.stringify(
                        {"phone": phone}
                    )),
                    dataType: "json",
                    async: false,
                    contentType: "application/json",
                    success: function (data) {
                        data=JSON.parse(receiveEncrypt(data));
                        if (data["result"] == "ok") {
                            layer.msg('发送成功', {time: 1000}, function () {

                            });
                        } else if (data["result"] == "exit") {
                            layer.msg('该手机号已经被注册！', {time: 1000}, function () {

                            });
                        } else {
                            layer.msg(data["result"], {time: 1000}, function () {
                            });
                        }

                    },
                    type: "post"
                });
            }
        }

    </script>

    <script>
        //注意：选项卡 依赖 element 模块，否则无法进行功能性操作
        layui.use('element', function(){
            var element = layui.element;

            //…
        });
    </script>
</head>
<body>
<div class="w">
    <div class="header-logo fl" ><h1><a th:href="@{/index}" style="color:#ea4949;">
        <img th:src="@{/myFile/imgold/icon/logo1.png}"style="width:100px;height:80px;"><strong>淘淘商城</strong></a></h1>
    </div>
</div>
<div id="content">
    <div class="login-wrap">
        <div class="w">
            <div class="login-form"style="top:20px;" >
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title">
                        <li class="layui-this"style="width:130px;float:left;">手机号注册</li>
                        <li style="width:130px;float:right">邮箱注册</li>
                    </ul>
                    <div class="layui-tab-content"style="padding:0px;">
                        <div class="layui-tab-item layui-show">
                            <div class="login-box">
                            <div class="msg-wrap"></div>
                            <div class="mc">
                                <div class="form">
                                    <form action="" id="formregister" method="post"onSubmit="return false;" >
                                        <div class="item item-fore1 item-error">
                                            <label for="phone" class="login-label name-label"></label>
                                            <input type="text" name="phone" id="phone" class="itxt" tabindex="1" autocomplete="off" placeholder="请输入手机号">
                                            <span class="clear-btn" style="display:inline;"></span>
                                        </div>
                                        <div class="item item-fore1 item-error">
                                            <label for="phone_auth_code" class="login-label name-label"></label>
                                            <input type="text" name="phone_auth_code" id="phone_auth_code" class="itxt1" tabindex="1" autocomplete="off" placeholder="请入验证码">
                                            <button onClick="phone_get_auth_code()" class="itxt2">获取</button>
                                            <span class="clear-btn" style="display:inline;"></span>
                                        </div>
                                        <!-- 密码输入框fore2 -->
                                        <div id="pwd" class="item item-fore2" style="visibility: visible">
                                            <label class="login-label pwd-label" for="phone_password"></label>
                                            <input type="password" id="phone_password" name="phone_password" class="itxt itxt-error" tabindex="2" autocomplete="off" placeholder="密码">
                                            <span class="clear-btn" style="display: inline;"></span>
                                            <span class="capslock" style="display: none;">
  			  					<b></b>
  			  					大小写锁定已打开
  			  				</span>
                                        </div>
                                        <div id="entry" class="item item-fore2" style="visibility: visible">
                                            <label class="login-label pwd-label" for="phone_confirm_password"></label>
                                            <input type="password" id="phone_confirm_password" name="phone_confirm_password" class="itxt itxt-error" tabindex="2" autocomplete="off" placeholder="确认密码">
                                            <span class="clear-btn" style="display: inline;"></span>
                                        </div>
                                        <!-- 自动登录开始fore4 -->
                                        <div class="item item-fore5">
                                            <div class="login-btn">
                                                <a href="javascript:;" class="btn-img btn-entry"  tabindex="6" onClick="phone_res()">注&nbsp;&nbsp;&nbsp;&nbsp;册</a>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="login-box1">
                                <div class="msg-wrap"></div>
                                <div class="mc">
                                    <div class="form">
                                        <form action="" id="formregister1" method="post" onSubmit="return false;">
                                            <div class="item item-fore1 item-error">
                                                <label for="email" class="login-label name-label"></label>
                                                <input type="text" name="email" id="email" class="itxt" tabindex="1" autocomplete="off" placeholder="请输入邮箱账户">
                                                <span class="clear-btn" style="display:inline;"></span>
                                            </div>
                                            <div class="item item-fore1 item-error">
                                                <label for="email_auth_code" class="login-label name-label"></label>
                                                <input type="text" name="email_auth_code" id="email_auth_code" class="itxt1" tabindex="1" autocomplete="off" placeholder="请入验证码">
                                                <button onclick="email_get_auth_code()" class="itxt2">获取</button>
                                                <span class="clear-btn" style="display:inline;"></span>
                                            </div>
                                            <!-- 密码输入框fore2 -->
                                            <div id="pwd1" class="item item-fore2" style="visibility: visible">
                                                <label class="login-label pwd-label" for="email_password"></label>
                                                <input type="password" id="email_password" name="email_password" class="itxt itxt-error" tabindex="2" autocomplete="off" placeholder="密码">
                                                <span class="clear-btn" style="display: inline;"></span>
                                                <span class="capslock" style="display: none;">
  			  					<b></b>
  			  					大小写锁定已打开
  			  				</span>
                                            </div>
                                            <div  class="item item-fore2" style="visibility: visible">
                                                <label class="login-label pwd-label" for="email_confirm_password"></label>
                                                <input type="password" id="email_confirm_password" name="email_confirm_password" class="itxt itxt-error" tabindex="2" autocomplete="off" placeholder="确认密码">
                                                <span class="clear-btn" style="display: inline;"></span>
                                            </div>

                                            <!-- 自动登录开始fore4 -->
                                            <!-- 登录按钮开始 -->
                                            <div class="item item-fore5">
                                                <div class="login-btn">
                                                    <a href="javascript:;" class="btn-img btn-entry"  tabindex="6" onClick="email_res()">注&nbsp;&nbsp;&nbsp;&nbsp;册</a>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="coagent" id="kbCoagent">
                    <ul>
                        <li class="extra-r">
                            <div class="regist-link">
                                <a href="/register" class="">
                                    <b></b>立即登录
                                </a>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="login-banner" style="background-color: #ea4949;">
            <div class="w">
                <div id="banner-bg" class="i-inner" style="background-image: url(/myFile/imgold/login/a1.jpg);"></div>
            </div>
        </div>
    </div>
</div>
<div class="w" >
    <div id="footer-2013">
        <div class="links">
            <a href="">关于我们</a>
            |
            <a href="">联系我们</a>
            |
            <a href="">人才招聘</a>
            |
            <a href="">商家入驻</a>
            |
            <a href="">广告服务</a>
            |
            <a href="">手机京东</a>
            |
            <a href="">友情链接</a>
            |
            <a href="">销售联盟</a>
            |
            <a href="">English site</a>
        </div>
        <div style="padding-left:10px">
            <p style="padding-top:10px; padding-bottom:10px; color:#999">网络文化经营许可证：浙网文[2013]0268-027号| 增值电信业务经营许可证：浙B2-20080224-1</p>
            <p style="padding-bottom:10px; color:#999">信息网络传播视听节目许可证：1109364号 | 互联网违法和不良信息举报电话:0571-81683755</p>
        </div>
    </div>
</div>

</body>

<script type="text/javascript">

</script>
</html>